package com.bbs.web;

import com.bbs.common.vo.DataResult;
import com.bbs.dto.ProfileUpdateDTO;
import com.bbs.dto.UpdatePasswordDTO;
import com.bbs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * UserController
 *
 * @author yangjiajia
 * @since 2024/5/9 17:34
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("update")
    public DataResult update(@Valid @RequestBody ProfileUpdateDTO updateDTO) {
        return DataResult.success(userService.update(updateDTO));
    }

    @PostMapping("updatePwd")
    public DataResult updatePwd(@Valid @RequestBody UpdatePasswordDTO updatePasswordDTO) {
        userService.updatePwd(updatePasswordDTO);
        return DataResult.success();
    }
}
